import axios from "axios";
const url = "http://127.0.0.1:8090";
const request = axios.create({
  baseURL: url,
  timeout: 5000,
  // withCredentials:true,//自动携带cookie
});

// 请求拦截器
request.interceptors.request.use(
  (config) => {
    // post请求需要添加时间戳
    // config.url = config.url + "?timestamp=" + Date.now();
    //  获取cookie
    // let cookie = localStorage.getItem("cookie") || "";
    // 如果不带cookie 出现301   访问无权限
    if (config.method.toLocaleLowerCase() == "get") {



      


      // config.params = { ...config.params, };
    } else {
      // config.data = { ...config.data, };

      // config.params = { ...config.params, cookie };
    } 


    //没有做逻辑
    return config;
  },
  (error) => {
    //对请求错误做些什么
    return Promise.reject(error);
  }
);

export default request;
